CC=gcc

LIB = ../lib/libthread.a
CFLAGS = 

ifeq ($(DEBUG),yes)
	CFLAGS = -W -Wall -g
endif 
ifeq ($(O_PRIORITE),yes)
	CFLAGS += -DO_PRIORITE
endif
ifeq ($(O_PREEMPTION),yes)
	CFLAGS += -DO_PREEMPTION
endif
ifeq ($(O_KILLCHILDREN),yes)
	CFLAGS += -DO_KILLCHILDREN
endif

LDFLAGS = 
SRC= $(wildcard *.c) 
OBJ= $(SRC:.c=.o)

all: $(LIB) clean

	@echo "\n*********************************************"
	@echo "*        RESULTATS DE LA COMPILATION        *"
	@echo "*********************************************"
	@echo "           [MODE DE COMPILATION]"
ifeq ($(DEBUG),yes)
	@echo "* mode debug"
else
	@echo "* mode libre"
endif

	@echo "            [POLITIQUE ADOPTEE]"

ifeq ($(O_PRIORITE),yes)
	@echo "* thread de plus grande priorite a la main"
else
	@echo "* thread 1er de la liste d'attente a la main"
endif

ifeq ($(O_PREEMPTION),yes)
	@echo "* ordonnancement par preemption"
else
	@echo "* ordonnancement par collaboration"
endif

ifeq ($(O_KILLCHILDREN),yes)
	@echo "* le pere tue ses enfants en quittant"
else
	@echo "* le pere ne tue pas ses enfants en quittant"
endif

	@echo "* le main est traité comme un thread"
	@echo "*********************************************\n"


$(LIB): $(OBJ) Makefile
	@ar -rv $@ $^
	ranlib $@

timer.o: timer.h
thread.o: thread.h
priorite.o: priorite.h 
fifoThread.o: fifoThread.h
my_semaphore.o: my_semaphore.h
threadStructure.o: threadStructure.h

%.o: %.c Makefile
	@$(CC) -o $@ -c $< $(CFLAGS)

.PHONY: clean

clean:
	rm -f *.o *~ *#